<script setup lang='ts'>
import { ref ,onMounted} from 'vue'
       const aDom=ref(null)//1.建立ref对象
       const bDom = ref(null)//2.建立ref对象
onMounted(()=>{
  
if(aDom.value){
    const dom = aDom.value as HTMLAnchorElement
    dom.href='https://www.qq.com'
}
if(bDom.value){
    const dom = bDom.value as HTMLButtonElement
    dom.onclick=()=>{
        alert('脱裤子放屁')
    }
}
}
)
</script>
       
<template>
       <h1>获取a标签的dom对象</h1>
       <a href="https://www.baidu.com">百度</a>
       <button ref="bDom">button的按钮</button>
</template>
       
<style scoped>
       
</style>